Skip to content

Added config option for auto-detecting plot content in Examples #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

duncanmmacleod
Copy link

This PR adds a new config option numpydoc_plot_examples_re to allow for easy customisation of the required content for inserting plot directives in Examples sections. The default remains 'import matplotlib'.

For example, if the user code doesn't include a direct matplotlib import, but rather imports pyplot as from matplotlib import pyplot, currently that wouldn't allow for auto-inserting a plot directive, but with the new parameter, they can tell numpydoc from the conf.py:

numpydoc_plot_examples_re = 'from matplotlib import pyplot'

elevates the hard-coded ``'import matplotlib'`` trigger for using matplotlib's plot directive to an extension config parameter, called `numpydoc_plot_examples_re`
@pv
Copy link
Member

pv commented Jun 12, 2017 via email

@pv
Copy link
Member

pv commented Jun 12, 2017 via email

@jnothman
Copy link
Member

If this was just about supporting from matplotlib import I'd suggest just changing the default. A regular expression would allow us to support things like DataFrame.plot, I suppose. Is than alternative which would inspect what happens during execution?

@jnothman
Copy link
Member

Given that .. plot:: is always an option for the user, I'd prefer just making a more expansive expression to cover the from matplotlib case as its current non-support is a bit surprising. Posting a PR now.

jnothman added a commit to jnothman/numpydoc that referenced this pull request Oct 24, 2017
jnothman added a commit to jnothman/numpydoc that referenced this pull request Oct 24, 2017
@pv pv closed this in #125 Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants